<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="我的动态" back-icon-color='#333333' height="50" :border-bottom="false">
			<view class="" style="margin-left: 600rpx; display: flex;align-content: center;"
				@click="$toLink('../add_vacate/add_vacate',{})">
				<image src="../../static/tupian95.png" mode="widthFix" style="width: 30rpx;"></image>
			</view>
		</u-navbar>
		<view class="" style="width:100%; height:20rpx;">
		</view>
		<view class="" style="width:100%; background-color: #fff; height:20rpx;">
		</view>
		<view class="teacherList">
			<view class="teacher" v-for="(item,index) in dynamic_list" :key="index">
				<view class="top">
					<view class="left_img">
						<image :src="item.dynamicUrl" mode="widthFix"> </image>
					</view>
					<view class="right_content">
						<view class="">
							<text style="overflow:hidden;">{{item.teacher_info.full_name}}</text>
							<text>(初一语文)</text>
						</view>
						<view class="">
							<text>{{item.text}}</text>
						</view>
					</view>
				</view>
				<view class="imgList">
					<image :src="i" mode="widthFix" v-for="(i,j) in item.photoList" :key="j"></image>
				</view>
				<view class="time">
					<text>{{item.dynamic_time}}</text>
					<image src="../../static/tupian132.png" mode="widthFix"></image>
				</view>
				<view class="comment">
					<view class="like" v-for="(ele,num) in item.like_name_arr" :key="num">
						<image src="../../static/tupian133.png" mode="widthFix"></image>
						<text>{{ele}}</text>
					</view>
					<view class="discuss">
						<view class="" v-for="(h,g) in item.comment_lists" :key="g">
							<text>{{h.user_info?h.user_info.full_name:''}}:</text>
							<text>{{h.content}}</text>
						</view>
					</view>
				</view>
				<view class="" style="width:710rpx; height:30rpx; margin-left:20rpx;border-bottom:1rpx solid #e5e5e5;">
				</view>
				<view class="" style="width:100%; height:30rpx;">
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	import time from '../../time.js'
	export default {
		data() {
			return {
				left_url: '../../static/tupian101.png',
				right_url: '../../static/tupian102.png',
				dynamicList: [],
			}
		},
		onLoad() {
			this.getSchoolNewsMomentLists();
		},
		computed: {
			dynamic_list() {
				if (this.dynamicList) {
					this.dynamicList.forEach(item => {
						this.$set(item, 'dynamicUrl', `${uni.getStorageSync('host')}${item.teacher_info
			.avatar_img}`)
						this.$set(item, 'dynamic_time', time.format(item.create_time));
						this.$set(item, 'photoList', item.pics.split(','))
					})
					return this.dynamicList;
				} else {
					return [];
				}
			}
		},
		methods: {
			getSchoolNewsMomentLists() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/moment/momentLists',
					method: 'post',
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data.data);
							_this.dynamicList = res.data.data.data;
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		background: #F2F2F2;

		.teacherList {
			width: 100%;
			background: #fff;
			overflow: hidden;

			.teacher {
				width: 100%;
				margin-top: 30rpx;
				background: #fff;

				.top {
					width: 100%;
					height: 121rpx;
					display: flex;
					justify-content: flex-start;

					.left_img {
						width: 111rpx;
						height: 121rpx;
						display: flex;
						justify-content: center;

						image {
							width: 60rpx;
						}
					}

					.right_content {
						width: 630rpx;

						view {
							&:nth-child(1) {
								width: 100%;
								height: 32rpx;
								display: flex;
								justify-content: flex-start;
								align-items: center;
								overflow: hidden;

								text {
									font-size: 30rpx;
									color: #5b6a91;

									&:nth-child(1) {
										width: 120rpx;
									}

									&:nth-child(2) {}
								}
							}

							&:nth-child(2) {
								width: 100%;
								margin-top: 30rpx;
								height: 28rpx;
								display: flex;
								justify-content: flex-start;
								align-items: center;

								text {
									font-size: 26rpx;
									color: #333333;

									&:nth-child(1) {
										width: 100%;
										overflow: hidden;
									}
								}
							}
						}
					}

				}

				.imgList {
					width: 100%;
					// height: 153rpx;
					flex-wrap: wrap;
					margin-top: 0;
					display: flex;
					justify-content: flex-start;

					image {
						margin-top: 0;



						&:nth-child(n+1) {
							margin-left: 30rpx;
							width: 153rpx;
							height: 153rpx;
						}

						&:nth-child(1) {
							margin-left: 111rpx;
							width: 153rpx;
							height: 153rpx;
						}

						&:nth-child(n+3) {
							margin-top: 10rpx;
						}

						&:nth-child(4) {
							margin-left: 111rpx;
							width: 153rpx;
							height: 153rpx;
						}

					}
				}

				.time {
					width: 100%;
					height: 69rpx;
					display: flex;
					justify-content: flex-start;

					text {
						&:nth-child(1) {
							margin-top: 27rpx;
							font-size: 22rpx;
							margin-left: 111rpx;
							color: #b7b7b7;
							width: 550rpx;
						}
					}

					image {
						&:nth-child(2) {
							width: 64rpx;
							margin-top: 22rpx;
						}
					}

				}

				.comment {
					width: 620rpx;
					margin-left: 111rpx;
					background: #f8f8f8;

					.like {
						width: 100%;
						height: 65rpx;
						box-sizing: border-box;
						border-bottom: 1rpx solid #e5e5e5;
						display: flex;
						align-items: center;
						justify-content: flex-start;

						image {
							&:nth-child(1) {
								width: 24rpx;
								margin-left: 15rpx;
							}
						}

						text {
							&:nth-child(2) {
								font-size: 24rpx;
								margin-left: 17rpx;
								color: #5b6a91;
							}
						}
					}

					.discuss {
						width: 100%;

						view {
							width: 100%;
							height: 65rpx;
							box-sizing: border-box;
							display: flex;
							align-items: center;
							justify-content: flex-start;

							text {
								&:nth-child(1) {
									font-size: 24rpx;
									margin-left: 15rpx;
									color: #5b6a91;
								}

								&:nth-child(2) {
									font-size: 24rpx;
									margin-left: 15rpx;
									color: #666666;
								}
							}
						}
					}
				}


			}
		}
	}
</style>
